﻿var keyValue = request('keyValue');
var fileType = request('fileType');
var acceptClick;
var bootstrap = function ($, learun) {
    "use strict";

    var moveFolderId = "";
    var page = {
        init: function () {
            page.GetTree();
        },
        //初始化控件
        GetTree: function () {
            $('#ItemsTree').lrtree({
                url: config.base_server() + 'filefolders/tree?access_token=' + config.getToken().access_token,
                nodeClick: function (item) {
                    moveFolderId = item.id;
                }
            });
            $("#ItemsTree_" + keyValue.replace(/-/g, '_')).parent('li').remove();
        }
    };
    //保存表单
    acceptClick = function (callBack) {
        if (moveFolderId == "") {
            learun.alert.error('请选择要移动到的位置');
            return false;
        }

        $.lrSaveForm(config.base_server() + 'fileinfos/move?keyValue=' + keyValue + '&moveFolderId=' + moveFolderId + '&fileType=' + fileType + '&access_token=' + config.getToken().access_token, {}, function (res) {
            // 保存成功后才回调
            if (!!callBack) {
                callBack();
            }
        });
    }
    page.init();
}